package com.work.saturn.assets;


import com.alibaba.android.arouter.facade.annotation.Route;
import com.immo.libcommon.base.BaseHeadActivity;
import com.immo.libcommon.constant.RouterUtil;
import com.work.saturn.utils.ZXingUtils;
import com.work.saturn.R;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.immo.libcommon.utils.CopyUtil.copyContent;

/**
 * @author Administrator
 * @content 转入
 * @date 2018/7/11
 */
@Route(path = RouterUtil.ASSETS_TURN_IN)
public class AssetsTurnInActivity extends BaseHeadActivity {
    @BindView(R.id.turn_in_zxing)
    ImageView zxing;
    @BindView(R.id.turn_in_account)
    TextView account;
    private String userId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_turn_in);
        ButterKnife.bind(this);
        setTitle(getString(R.string.money_code));
        userId = getIntent().getStringExtra("userId");
        initUI();
    }

    /**
     * 初始化UI
     */
    @SuppressLint("SetTextI18n")
    private void initUI() {
        account.setText(getString(R.string.address) + userId);
        Bitmap bitmap = ZXingUtils.createQRImage(getIntent().getStringExtra("userId"), 600, 600);
        zxing.setImageBitmap(bitmap);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @OnClick({R.id.turn_in_zxing, R.id.turn_in_copy})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.turn_in_zxing:
                //复制用户名
                copyContent(this, userId);
                break;
            case R.id.turn_in_copy:
                //复制用户名
                copyContent(this, userId);
                break;
        }
    }
}
